home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inside Mac Games Volume 5 #3
/
IMG 46 Vol 5-3.iso
/
More Goodies
/
More For Your Game
/
Realmz
/
Character Master Source
/
Nemesis Framework
/
Sources
/
nemesis misc utilities.cpp
< prev
next >
Wrap
Text File
|
1996-07-03
|
3KB
|
159 lines
//•••••••••••••••••••••••••••••••
// Some miscellaneous utilities
//•••••••••••••••••••••••••••••••
#ifndef __QDOFFSCREEN__
#include"QDOffscreen.h"
#endif
#ifndef __PALETTES__
#include "Palettes.h"
#endif
Boolean NemesisIsTrapAvailable( int trapNum )
{
TrapType trapType;
int numToolboxTraps;
if (trapNum & 0x0800)
{
trapType = ToolTrap;
}
else
{
trapType = OSTrap;
}
if (trapType == ToolTrap)
{
trapNum = trapNum & 0x07FF;
if (NGetTrapAddress(_InitGraf,ToolTrap) ==
NGetTrapAddress(0xAA6E, ToolTrap))
{
numToolboxTraps = 0x0200;
}
else
{
numToolboxTraps = 0x0400;
}
if ( trapNum > numToolboxTraps)
{
return(false);
}
}
return( NGetTrapAddress(trapNum, trapType) !=
NGetTrapAddress(_Unimplemented, ToolTrap));
}
Boolean NemesisWithinLimits( long theValue, long lowerLimit, long upperLimit )
{
if( (theValue < lowerLimit) || (theValue > upperLimit) )
return false;
else
return true;
}
GDHandle NemesisGetRectsDevice( Rect theRect )
{
SInt32 greatestArea, intersectArea;
GDHandle deviceHdl = nil, deviceHdlToReturn = GetMainDevice();
Rect intersectRect;
LocalToGlobal( &topLeft(theRect) );
LocalToGlobal( &botRight(theRect) );
deviceHdl = LMGetDeviceList();
greatestArea = 0;
while( deviceHdl != nil )
{
if( TestDeviceAttribute(deviceHdl,screenDevice) &&
TestDeviceAttribute(deviceHdl,screenActive) &&
SectRect(&theRect,&(*deviceHdl)->gdRect,&intersectRect))
{
intersectArea = (SInt32) ( intersectRect.right - intersectRect.left ) *
( intersectRect.bottom - intersectRect.top );
if( intersectArea > greatestArea )
{
greatestArea = intersectArea;
deviceHdlToReturn = deviceHdl;
}
}
deviceHdl = GetNextDevice( deviceHdl );
}
return deviceHdlToReturn;
}
int NemesisMainDeviceDepth()
{
GDHandle mainDevice = nil;
int currDepth = 1;
mainDevice = GetMainDevice();
if( mainDevice ) // Check for nil
{
currDepth = (*( (**mainDevice).gdPMap ))->pixelSize;
}
return currDepth;
}
Boolean NemesisSetDimmedColour( Rect theRect, RGBColor &oldForeColour )
{
RGBColor backColour, newForeColour;
GDHandle targetDevice;
Boolean newGrey = false;
if( NemesisMainDeviceDepth() > 1 )
{
GetBackColor( &backColour );
GetForeColor( &oldForeColour );
newForeColour = oldForeColour;
targetDevice = NemesisGetRectsDevice( theRect );
if( targetDevice ) // Check for nil
newGrey = GetGray( targetDevice, &backColour, &newForeColour );
}
if(newGrey)
RGBForeColor( &newForeColour );
else
PenPat( &qd.gray );
return newGrey;
}
void NemesisRestoreDimmedColour( RGBColor oldForeColour )
{
RGBForeColor(&oldForeColour);
}
Boolean NemesisOptionKeyDown()
{
KeyMap theKeys;
GetKeys( theKeys );
if( BitTst( &theKeys[1], kOptionKeyDown ) )
return true;
else
return false;
}
Boolean NemesisControlKeyDown()
{
KeyMap theKeys;
GetKeys( theKeys );
if( BitTst( &theKeys[1], kControlKeyDown ) )
return true;
else
return false;
}
void NemesisPlaySound( int theSoundID )
{
SHPlayByID( theSoundID, nil );
}